package com.cloudptt.wp.ui.message.sub.view;

import android.widget.ImageView;
import android.widget.LinearLayout;
import android.content.Context;
import android.util.AttributeSet;

public class MaxSizeImageView extends ImageView {

    private int maxWidth = 150; // 设置最大宽度
    private int maxHeight = 150; // 设置最大高度

    public MaxSizeImageView(Context context) {
        super(context);
    }

    public MaxSizeImageView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public MaxSizeImageView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int width = MeasureSpec.getSize(widthMeasureSpec);
        width = Math.min(width, maxWidth);
        int height = MeasureSpec.getSize(heightMeasureSpec);
        height = Math.min(height, maxHeight);
        setMeasuredDimension(width, height);
    }
}
